<?php
/*
 * MiniMe - a minimalistic OStatus complient microblogging tool
 * Copyright (C) 2010, Tuomas Koski - koski.tuomas@gmail.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @author     Tuomas Koski <koski.tuomas@gmail.com>
 * @copyright  Tuomas Koski
 * @license    http://www.gnu.org/licenses/lgpl.txt
 */
$basedir = dirname(__FILE__);

require_once $basedir . '/../../../classes/minime/helpers.php';

class Minime_HelpersTest extends PHPUnit_Framework_TestCase {
    
    public function testParseRecepientsFromMicroblogNote(){
        $str = "@pamela@google.com,@jon@google.com - yes, that makes lot's of sence. #julie@identi.ca,#simon@buddycloud.com is in this picture too.";
        
        $old['to'] = array('tkoski@identi.ca');
        //$old['tag'] = array('tkoski@identi.ca');
        
        $expected['to'] = array('tkoski@identi.ca', 'pamela@google.com', 'jon@google.com');
        $expected['tag'] = array('julie@identi.ca', 'simon@buddycloud.com');
        
        //$new = Minime_Helpers::parseRecepientsFromMicroblogNote($str);
        
        //$receivers = array_merge($old, Minime_Helpers::parseRecepientsFromMicroblogNote($str, $old));
        $receivers = Minime_Helpers::parseRecepientsFromMicroblogNote($str, $old);
        //$receivers['to'] = array_merge($old['to'], $new['to']);
        //$receivers['tag'] = array_merge($old['tag'], $new['tag']);
        
        $this->assertEquals($expected['to'], $receivers['to']);
        $this->assertEquals($expected['tag'], $receivers['tag']);
    }
    
    public function testParseRecepientsFromMicroblogNoteWhenNothingIsFound(){
        $str = "yes, that makes lot's of sence.";
        
        $old['to'] = array('tkoski@identi.ca');
        
        $expected['to'] = array('tkoski@identi.ca');
        
        //$receivers = array_merge($old, Minime_Helpers::parseRecepientsFromMicroblogNote($str));
        $receivers = Minime_Helpers::parseRecepientsFromMicroblogNote($str, $old);
        
        $this->assertEquals($expected['to'], $receivers['to']);
    }
    
}